import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Antd, {message} from 'ant-design-vue'
import 'ant-design-vue/dist/reset.css';
import * as Icons from '@ant-design/icons-vue'
import axios from "axios";
axios.defaults.baseURL = process.env.VUE_APP_SERVER
const mount = createApp(App);
    mount.use(store).use(router).use(Antd).mount('#app');
const icons:any = Icons;
for(const i in icons) {
    mount.component(i)
}
axios.interceptors.request.use(function (config) {
    console.log('请求参数：', config);
    return config;
}, error => {
    return Promise.reject(error);
});
axios.interceptors.response.use(function (response) {
    console.log('返回结果：', response);
    return response;
}, error => {
    console.log('返回错误：', error);
    return Promise.reject(error);
});

axios.interceptors.response.use(
    response => {
        // 对响应数据进行处理
        return response;
    },
    error => {
        if (error.response) {
            // 处理后端返回的异常响应
            const { data } = error.response;
            if (data && !data.success) {
                // 显示异常提示弹窗
                message.error(data.message);
            }
            console.log(data)
        } else {
            // 处理网络错误或其他异常
            message.error('网络错误,请稍后重试');

        }
        return Promise.reject(error);
    }
);
console.log('环境:',process.env.VUE_APP_SERVER)